home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3.iso
/
chapte20
/
ex8.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-22
|
3KB
|
64 lines
#include <genstub.c>
#define EDIT_ID 1000 // Identifies the child window.
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE: // Create an edit box control to manipulate section contents.
{
TCHAR szBuffer[256];
LPTSTR lpTemp = szBuffer;
LRESULT lRetVal = DefWindowProc( hWnd, uMsg, wParam, lParam );
wsprintf( lpTemp, "FirstKey = %d", 1 );
lpTemp += lstrlen(lpTemp) + 1;
wsprintf( lpTemp, "SecondKey = %s", "Two" );
lpTemp += lstrlen(lpTemp) + 1;
*lpTemp = 0;
WritePrivateProfileSection( "TestSection", // section
szBuffer, // buffer
"YOUR.INI" ); // INI file name
return lRetVal;
}
case WM_COMMAND: // process menu items
switch ( LOWORD( wParam ) )
{
case IDM_TEST:
{
int iRow = 0;
HDC hDC = GetDC( hWnd );
LPTSTR lpIniValuesBuffer = HeapAlloc( GetProcessHeap(),
HEAP_ZERO_MEMORY,
256 );
LPTSTR lpTemp = lpIniValuesBuffer;
GetPrivateProfileSection( "TestSection", // Section name
lpIniValuesBuffer, // Buffer
256, // Buffer size
"YOUR.INI" ); // INI file name.
while (*lpTemp)
{
TextOut( hDC, 0, iRow++ * 20, lpTemp, lstrlen(lpTemp) );
lpTemp += lstrlen(lpTemp) + 1;
}
HeapFree( GetProcessHeap(), 0L, lpIniValuesBuffer );
ReleaseDC( hWnd, hDC );
}
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
return( 0L ) ;
}
#include <about.c>